package Rainwater.controller;

import Rainwater.Service.AnalysisService;
import Rainwater.Service.PointService;
import Rainwater.baen.vo.IndexFigVo;
import Rainwater.baen.vo.IndexMapPointVo;
import Rainwater.baen.R;
import Rainwater.baen.vo.IndexPointVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.servlet.ModelAndView;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;

/**
 * @author cfy
 * @date 2024/10/15
 **/
@Controller
@RequestMapping("/rainwater/page")
public class IndexController {
    @Autowired
    private PointService pointService;
    @Autowired
    private AnalysisService analysisService;
    private R r = new R();
    @GetMapping("/index")
    public ModelAndView pageIndex(){
        ModelAndView modelAndView = new ModelAndView();
        modelAndView.setViewName("index");
        return modelAndView;
    }

    @ResponseBody
    @PostMapping("/index/figData")
    public R pageIndexFigProvince(@RequestBody String fun){
        IndexFigVo indexFigVo= new IndexFigVo();
        indexFigVo.setMap(analysisService.pointFig());
        indexFigVo.setStr(analysisService.userFig());
        return r.success(indexFigVo);
    }
    @ResponseBody
    @PostMapping("/index/map")
    public R pageIndexMap(@RequestBody String fun){
        ArrayList<IndexPointVo> indexPoints = pointService.getIndexPoints();
        return r.success(indexPoints);
    }
    @ResponseBody
    @PostMapping("/index/mapData")
    public R IndexMapData(Integer id){
        IndexMapPointVo pointVo = pointService.getMapPoint(id);
        return r.success(pointVo);
    }
}
